Framework
Physical representation of connected player.
Player
s are a type of Entity
. They are a physical representation of a Character
- and can possess at most one Character
object at a time that you can interface with.
See the Garry's Mod Wiki for all other methods that the Player
class has.
Functions
playerMeta:HasPrivilege(privilegeName)
Checks if the player has a specified CAMI privilege.
Parameters
-
privilegeName
string The name of the privilege to check.
Returns
-
boolean
True if the player has the privilege, false otherwise.
playerMeta:Name()
Returns this player's current name.
Returns
playerMeta:PlaySound(sound, volume, pitch, shouldEmit)
Plays a sound for the player.
Parameters
-
sound
String
The sound to play.
-
volume
Integer
optional
The volume of the sound (default 75).
-
pitch
Integer
optional
The pitch of the sound (default 100).
-
shouldEmit
Boolean
optional
Whether to emit sound server-side or send it to the client.
playerMeta:addMoney(amount)
Adds money to the player's character. This function uses Lilia methods to add the specified amount of money to the player. It is designed to be compatible with the DarkRP addMoney method. If the total amount exceeds the configured money limit, the excess is spawned as an item in the world.
Parameters
-
amount
Integer
The amount of money to add.
playerMeta:binaryQuestion(question, option1, option2, manualDismiss, callback)
Requests a binary choice from the player.
Parameters
-
question
String
The question to present to the player.
-
option1
String
The text for the first option.
-
option2
String
The text for the second option.
-
manualDismiss
Boolean
Whether the notice should be manually dismissed.
-
callback
Function
The function to call with the choice (0 or 1) when the player selects an option.
playerMeta:canAfford(amount)
Checks if the player's character can afford a specified amount of money. This function uses Lilia methods to determine if the player can afford the specified amount. It is designed to be compatible with the DarkRP canAfford method.
Parameters
-
amount
Integer
The amount of money to check.
Returns
-
bool
Whether the player's character can afford the specified amount of money.
playerMeta:chatNotify(message)
Displays a notification for this player in the chatbox.
Parameters
-
message
String
Text to display in the notification
playerMeta:chatNotify(message)
Displays a notification for this player in the chatbox.
Parameters
-
message
String
Text to display in the notification
playerMeta:chatNotifyLocalized(message, ...)
Displays a notification for this player in the chatbox with the given language phrase.
Parameters
-
message
String
ID of the phrase to display to the player
-
...
Arguments to pass to the phrase
playerMeta:chatNotifyLocalized(message, ...)
Displays a notification for this player in the chatbox with the given language phrase.
Parameters
-
message
String
ID of the phrase to display to the player
-
...
Arguments to pass to the phrase
playerMeta:createRagdoll(freeze)
Creates a ragdoll entity for the player.
Parameters
-
freeze
Boolean
Whether to freeze the ragdoll initially.
Returns
-
Entity
The created ragdoll entity.
playerMeta:createServerRagdoll(dontSetPlayer)
Creates a ragdoll entity for the player on the server.
Parameters
-
dontSetPlayer
Boolean
optional
Determines whether to associate the player with the ragdoll.
Returns
-
Entity
The created ragdoll entity.
playerMeta:distanceFromEnt(entity)
Calculates the distance from the player to the specified entity.
Parameters
-
entity
Entity
The entity to calculate the distance to.
Returns
-
number
The distance from the player to the entity.
playerMeta:doStaredAction(entity, callback, time, onCancel, distance)
Performs a stared action towards an entity for a certain duration.
Parameters
-
entity
Entity
The entity towards which the player performs the stared action.
-
callback
Function
The function to call when the stared action is completed.
-
time
Integer
optional
The duration of the stared action in seconds.
-
onCancel
Function
optional
The function to call if the stared action is canceled.
-
distance
Integer
optional
The maximum distance for the stared action.
playerMeta:entitiesNearPlayer(radius, playerOnly)
Retrieves entities near the player within a specified radius.
Parameters
-
radius
Integer
The radius within which to search for entities.
-
playerOnly
Boolean
optional
If true, only return player entities.
Returns
-
table
A table containing the entities near the player.
playerMeta:getChar()
Returns this player's currently possessed Character
object if it exists.
Returns
-
Character
Currently loaded character
-
nil
If this player has no character loaded
playerMeta:getCurrentVehicle()
Gets the current vehicle the player is in, if any.
Returns
-
Entity or nil
The current vehicle entity, or nil if the player is not in a vehicle.
playerMeta:getDarkRPVar(var)
Retrieves the player's DarkRP money. This is used as compatibility for DarkRP Vars.
Parameters
-
var
string
The DarkRP variable to fetch (only "money" is allowed).
Returns
-
number or nil
The player's money if the variable is valid, or nil if not.
playerMeta:getEyeEnt(distance)
Retrieves the entity within the player's line of sight.
Parameters
-
distance
Integer
optional
The maximum distance to consider.
Returns
-
Entity or nil
The entity within the player's line of sight, or nil if not found.
playerMeta:getItemDropPos()
Calculates the position to drop an item from the player's inventory.
Returns
-
Vector
The position to drop an item from the player's inventory.
playerMeta:getItemWeapon()
Retrieves the active weapon item of the player.
Returns
-
Entity or nil
The active weapon entity of the player, or nil if not found.
playerMeta:getItems()
Retrieves the items of the player's character inventory.
Returns
-
table or nil
A table containing the items in the player's character inventory, or nil if not found.
playerMeta:getLiliaData(key, default)
Retrieves a value from the local Lilia data.
Parameters
-
key
String
The key for the data.
-
default
optional
The default value to return if the key does not exist.
Returns
-
any
The value corresponding to the key, or the default value if the key does not exist.
playerMeta:getLiliaData(key, default)
Retrieves a value from the player's Lilia data.
Parameters
-
key
String
The key for the data.
-
default
[opt=nil] The default value to return if the key does not exist.
Returns
-
any
The value corresponding to the key, or the default value if the key does not exist.
playerMeta:getMoney()
Retrieves the amount of money owned by the player's character.
Returns
-
number
The amount of money owned by the player's character.
playerMeta:getPlayTime()
Retrieves the player's total playtime.
Returns
-
number
The total playtime of the player.
playerMeta:getPlayTime()
Retrieves the player's total playtime.
Returns
-
number
The total playtime of the player.
playerMeta:getRagdoll()
Returns the player's ragdoll entity if valid.
Returns
-
Entity or nil
The player's ragdoll entity if it exists and is valid, otherwise nil.
playerMeta:getTrace()
Performs a trace from the player's view.
Returns
-
table
A table containing the trace result.
playerMeta:getTracedEntity()
Retrieves the entity traced by the player's aim.
Returns
-
Entity or nil
The entity traced by the player's aim, or nil if not found.
playerMeta:hasRagdoll()
Checks if the player has a valid ragdoll entity.
Returns
-
bool
Whether the player has a valid ragdoll entity.
playerMeta:hasValidVehicle()
Checks if the player is in a valid vehicle.
Returns
-
bool
true if the player is in a valid vehicle, false otherwise.
playerMeta:isFemale()
Checks if the player's character is female based on the model.
Returns
-
bool
Whether the player's character is female.
playerMeta:isMoving()
Checks if the player is currently moving.
Returns
-
bool
Whether the player is currently moving.
playerMeta:isNearPlayer(radius, entity)
Checks if the player is near another entity within a specified radius.
Parameters
-
radius
Integer
The radius within which to check for proximity.
-
entity
Entity
The entity to check proximity to.
Returns
-
bool
Whether the player is near the specified entity within the given radius.
playerMeta:isNoClipping()
Checks if the player is currently in noclip mode.
Returns
-
bool
Whether the player is in noclip mode.
playerMeta:isObserving()
Checks if the player is currently observing.
Returns
-
bool
Whether the player is currently observing.
playerMeta:isOutside()
Checks if the player is currently outside (in the sky).
Returns
-
bool
Whether the player is currently outside (in the sky).
playerMeta:isRunning()
Checks if the player is running.
Returns
-
bool
Whether the player is running.
playerMeta:isStuck()
Checks if the player is stuck.
Returns
-
bool
Whether the player is stuck.
playerMeta:loadLiliaData(callback)
Loads Lilia data for the player from the database.
Parameters
-
callback
Function
optional
Function to call after the data is loaded, passing the loaded data as an argument.
playerMeta:notify(message)
Notifies the player with a message.
Parameters
-
message
String
The message to notify the player.
playerMeta:notifyLocalized(message, ...)
Notifies the player with a localized message.
Parameters
-
message
String
The key of the localized message to notify the player.
-
...
Table
Additional arguments to format the localized message.
playerMeta:notifyP(text)
Notifies the player with a message and prints the message to their chat.
Parameters
-
text
String
The message to notify and print.
playerMeta:openPage(url)
Opens a web page for the player.
Parameters
-
url
String
The URL of the web page to open.
playerMeta:openUI(panel)
Opens a VGUI panel for the player.
Parameters
-
panel
The name of the VGUI panel to open.
playerMeta:openUI(panel)
Opens a UI panel for the player.
Parameters
-
panel
The panel type to create.
Returns
-
Panel
The created UI panel.
playerMeta:requestDropdown(title, subTitle, options, callback)
Requests a dropdown selection from the player.
Parameters
-
title
String
The title of the request.
-
subTitle
String
The subtitle of the request.
-
options
Table
The table of options to choose from.
-
callback
Function
The function to call upon receiving the selected option.
playerMeta:requestOptions(title, subTitle, options, limit, callback)
Requests multiple options selection from the player.
Parameters
-
title
String
The title of the request.
-
subTitle
String
The subtitle of the request.
-
options
Table
The table of options to choose from.
-
limit
number
The maximum number of selectable options.
-
callback
Function
The function to call upon receiving the selected options.
playerMeta:requestString(title, subTitle, callback, default)
Requests a string input from the player.
Parameters
-
title
String
The title of the string input dialog.
-
subTitle
String
The subtitle or description of the string input dialog.
-
callback
Function
The function to call with the entered string.
-
default
optional
The default value for the string input.
Returns
-
Promise
A promise object resolving with the entered string.
playerMeta:saveLiliaData()
Saves the player's Lilia data to the database.
playerMeta:setAction(text, time, callback, startTime, finishTime)
Sets an action bar for the player.
Parameters
-
text
String
The text to display on the action bar.
-
time
Integer
optional
The duration for the action bar to display, defaults to 5 seconds. Set to 0 or nil to remove the action bar immediately.
-
callback
Function
optional
Function to execute when the action bar timer expires.
-
startTime
Integer
optional
The start time of the action bar, defaults to the current time.
-
finishTime
Integer
optional
The finish time of the action bar, defaults to startTime + time.
playerMeta:setLiliaData(key, value, noNetworking)
Sets a key-value pair in the player's Lilia data.
Parameters
-
key
String
The key for the data.
-
value
The value to set.
-
noNetworking
Boolean
optional
If true, suppresses network broadcasting of the update.
playerMeta:setLocalVar(key, value)
Sets a local variable for the player.
Parameters
-
key
String
The key of the variable.
-
value
The value of the variable.
playerMeta:setRagdoll(entity)
Sets the player's ragdoll entity.
Parameters
-
entity
Entity
The entity to set as the player's ragdoll.
playerMeta:setRagdolled(state, time, getUpGrace, getUpMessage)
Sets the player to a ragdolled state or removes the ragdoll.
Parameters
-
state
Boolean
Whether to set the player to a ragdolled state (
true
) or remove the ragdoll (false
).
-
time
Integer
optional
The duration for which the player remains ragdolled.
-
getUpGrace
Integer
optional
The grace period for the player to get up before the ragdoll is removed.
-
getUpMessage
String
optional
The message displayed when the player is getting up.
playerMeta:setWeighPoint(name, vector, onReach)
Sets a waypoint for the player.
Parameters
-
name
String
The name of the waypoint.
-
vector
Vector
The position vector of the waypoint.
-
onReach
Function
[opt=nil] Function to call when the player reaches the waypoint.
playerMeta:squaredDistanceFromEnt(entity)
Calculates the squared distance from the player to the specified entity.
Parameters
-
entity
Entity
The entity to calculate the distance to.
Returns
-
number
The squared distance from the player to the entity.
playerMeta:stopAction()
Stops the action bar for the player. Removes the action bar currently being displayed.
playerMeta:syncVars()
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Synchronizes networked variables with the player.
playerMeta:takeMoney(amount)
Takes money from the player's character.
Parameters
-
amount
Integer
The amount of money to take.